<?php
/**
 * Created by PhpStorm.
 * User: refar
 * Date: 21-2-19
 * Time: 下午3:59
 */

namespace app\s\controller;
use think\Controller;

class S extends Controller
{
    /**
        define('ADMIN', 8);
        define('T_MANAGER', 6);
        define('S_MANAGER', 20);
        define('ST_MANAGER', 21);
        define('EMS_ADMIN', 14);
        define('COMMON_USER', 16);
     */
    public function changeSampleRole() {
        $r = $this->request->param('r');
        $roleFile = RUNTIME_PATH. 'roleId.txt';

        $file = fopen($roleFile,"w");
        file_put_contents($roleFile, $r);

        fclose($file);

        return apiResponse(SUCCESS);
    }
    public function changeRole() {
        $index = $this->request->param('i');
        /**
         * 销售	销售管理员	销售部长	总经理	财务课长	财务部长
           借出	借用者(随意)	总经理(DBT)	销售部长(DBH)	GM(DBH)	销售管理员
           删除	销售管理员	总经理(DBT)	销售部长(DBH)	GM(DBH)	销售管理员
         */
        $roleArray = array(['roleId'=>'23', 'depart'=>'销售部'],
                           ['roleId'=>'24', 'depart'=>'销售部'],
                           ['roleId'=>'22', 'depart'=>'总经办'],
                           ['roleId'=>'20', 'depart'=>'财务部'],
                           ['roleId'=>'24', 'depart'=>'财务部'],

                           ['roleId'=>'23', 'depart'=>'销售部'],
                           ['roleId'=>'22', 'depart'=>'总经办'],
                           ['roleId'=>'24', 'depart'=>'销售部'],
                           ['roleId'=>'25', 'depart'=>'总经办'],
                           ['roleId'=>'23', 'depart'=>'销售部'],

                           ['roleId'=>'23', 'depart'=>'销售部'],
                           ['roleId'=>'22', 'depart'=>'总经办'],
                           ['roleId'=>'24', 'depart'=>'销售部'],
                           ['roleId'=>'25', 'depart'=>'总经办'],
                           ['roleId'=>'23', 'depart'=>'销售部']
            );

        // 判断runtime下是否有roleId.txt文件
        $roleFile = RUNTIME_PATH. 'roleId.txt';

        $file = fopen($roleFile,"w");
        file_put_contents($roleFile, $roleArray[$index]['roleId'] . '&'. $roleArray[$index]['depart']);

        fclose($file);

        return apiResponse(SUCCESS);

    }
}